package net.jlibrary.computer.action.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import net.jlibrary.common.CoreConstants;
import net.jlibrary.common.core.annotation.VoForPo;
import net.jlibrary.common.core.entity.BaseVo;
import net.jlibrary.computer.domain.Computer;
import net.jlibrary.computer.domain.ComputerType;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@VoForPo(Computer.class)
public class ComputerVo extends BaseVo {

    private Long id;
    private String name;

    private BigDecimal price;

    private ComputerTypeVo type;
    private ComputerTypeVo typeSearchKey;

    @DateTimeFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT)
    @JsonFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT, timezone = CoreConstants.DATE_TIMEZONE_DEFAULT)
    private Date createdate;
    @DateTimeFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT)
    @JsonFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT, timezone = CoreConstants.DATE_TIMEZONE_DEFAULT)
    private Date lastdate;
    private String nameSearchKey;


    public ComputerVo() {
        type = new ComputerTypeVo();
        typeSearchKey = new ComputerTypeVo();
    }

    private Integer type_id;

    public Integer getType_id() {
        return type_id;
    }

    public void setType_id(Integer type_id) {
        this.type_id = type_id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public ComputerTypeVo getTypeSearchKey() {
        return typeSearchKey;
    }

    public void setTypeSearchKey(ComputerTypeVo typeSearchKey) {
        this.typeSearchKey = typeSearchKey;
    }

    public ComputerTypeVo getType() {
        return type;
    }

    public void setType(ComputerTypeVo type) {
        this.type = type;
    }

    public String getNameSearchKey() {
        return nameSearchKey;
    }

    public void setNameSearchKey(String nameSearchKey) {
        this.nameSearchKey = nameSearchKey;
    }

    @Override
    public Serializable getPrimaryKey() {
        return id;
    }

    @Override
    public Serializable getText() {
        return name;
    }

    @Override
    public Date getCreatedate() {
        return createdate;
    }

    @Override
    public Date getLastdate() {
        return lastdate;
    }

    @Override
    public void setCreatedate(Date createdate) {
        this.createdate = createdate;
    }

    @Override
    public void setLastdate(Date lastdate) {
        this.lastdate = lastdate;
    }

    @VoForPo(ComputerType.class)
    public class ComputerTypeVo extends BaseVo {

        private Long id;

        private String name;
        @DateTimeFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT)
        @JsonFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT, timezone = CoreConstants.DATE_TIMEZONE_DEFAULT)
        private Date createdate;
        @DateTimeFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT)
        @JsonFormat(pattern = CoreConstants.DATETIME_FORMAT_DEFAULT, timezone = CoreConstants.DATE_TIMEZONE_DEFAULT)
        private Date lastdate;


        @Override
        public Serializable getPrimaryKey() {
            return id;
        }

        @Override
        public Serializable getText() {
            return name;
        }

        @Override
        public Date getCreatedate() {
            return createdate;
        }

        @Override
        public Date getLastdate() {
            return lastdate;
        }

        @Override
        public void setCreatedate(Date createdate) {
            this.createdate = createdate;
        }

        @Override
        public void setLastdate(Date lastdate) {
            this.lastdate = lastdate;
        }

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getNameSearchKey() {
            return nameSearchKey;
        }

    }

}
